package com.ktgj.service.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ktgj.common.log.annotation.Log;
import com.ktgj.common.log.enums.BusinessType;
import com.ktgj.common.security.annotation.PreAuthorize;
import com.ktgj.service.domain.ViphallComment;
import com.ktgj.service.service.IViphallCommentService;
import com.ktgj.common.core.web.controller.BaseController;
import com.ktgj.common.core.web.domain.AjaxResult;
import com.ktgj.common.core.utils.poi.ExcelUtil;
import com.ktgj.common.core.web.page.TableDataInfo;

/**
 * 贵宾厅评论Controller
 * 
 * @author ruoyi
 * @date 2021-11-22
 */
@ControllerAdvice
@RestController
@RequestMapping("/comment")
public class ViphallCommentController extends BaseController
{
    @Autowired
    private IViphallCommentService viphallCommentService;

    /**
     * 查询贵宾厅评论列表
     */
    //@PreAuthorize(hasPermi = "service:comment:list")
    @GetMapping("/list")
    public TableDataInfo list(ViphallComment viphallComment)
    {
        startPage();
        List<ViphallComment> list = viphallCommentService.selectViphallCommentList(viphallComment);
        return getDataTable(list);
    }

    /**
     * 导出贵宾厅评论列表
     */
    //@PreAuthorize(hasPermi = "service:comment:export")
    @Log(title = "贵宾厅评论", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ViphallComment viphallComment) throws IOException
    {
        List<ViphallComment> list = viphallCommentService.selectViphallCommentList(viphallComment);
        ExcelUtil<ViphallComment> util = new ExcelUtil<ViphallComment>(ViphallComment.class);
        util.exportExcel(response, list, "贵宾厅评论数据");
    }

    /**
     * 获取贵宾厅评论详细信息
     */
    //@PreAuthorize(hasPermi = "service:comment:query")
    @GetMapping(value = "/{commentId}")
    public AjaxResult getInfo(@PathVariable("commentId") Long commentId)
    {
        return AjaxResult.success(viphallCommentService.selectViphallCommentById(commentId));
    }

    /**
     * 新增贵宾厅评论
     */
    //@PreAuthorize(hasPermi = "service:comment:add")
    @Log(title = "贵宾厅评论", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ViphallComment viphallComment)
    {
        return toAjax(viphallCommentService.insertViphallComment(viphallComment));
    }

    /**
     * 修改贵宾厅评论
     */
    //@PreAuthorize(hasPermi = "service:comment:edit")
    @Log(title = "贵宾厅评论", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ViphallComment viphallComment)
    {
        return toAjax(viphallCommentService.updateViphallComment(viphallComment));
    }

    /**
     * 删除贵宾厅评论
     */
    //@PreAuthorize(hasPermi = "service:comment:remove")
    @Log(title = "贵宾厅评论", businessType = BusinessType.DELETE)
	@DeleteMapping("/{commentIds}")
    public AjaxResult remove(@PathVariable Long[] commentIds)
    {
        return toAjax(viphallCommentService.deleteViphallCommentByIds(commentIds));
    }
}
